// 引入mockjs
// const Mock = require('mockjs')
import Mock from 'mockjs'
// 获取 mock.Random 对象
const Random = Mock.Random

// 家人数据
const family = () => {
  let data = [
    {
      id:1,
      name: 'name1',
      phone: '13542154787'
    },
    {
      id: 2,
      name: 'name2',
      phone: '13542154787'
    },
    {
      id: 3,
      name: 'name3',
      phone: '13542154787'
    },
  ]
  return {
    data: data
  }
}

const delFamily = (id) => {
  id = id.body.split('=')[1]
  // console.log('id11-- ',id);
}

const addFmaily = (options) => {
  // let arr = family()
  // console.log(options.body.split('&')[0].split('=')[1]);
  // arr.push({
  //   id: arr.length - 1,
  //   name: options.body.split('&')[0].split('=')[1],
  //   phone: options.body.split('&')[1].split('=')[1]
  // })
  // return arr
}

const getDataDetail = (options) => {
  let content = {
    result: 200,
    data: [
      {
        time: '2019-02-24 10:30:24',
        bpm: '96',
        mmhg: '98/120'
      },
      {
        time: '2019-02-24 10:30:24',
        bpm: '96',
        mmhg: '98/120'
      },
      {
        time: '2019-02-24 10:30:24',
        bpm: '96',
        mmhg: '98/120'
      },
      {
        time: '2019-02-24 10:30:24',
        bpm: '96',
        mmhg: '98/120'
      },
      {
        time: '2019-02-24 10:30:24',
        bpm: '96',
        mmhg: '98/120'
      },
      {
        time: '2019-02-24 10:30:24',
        bpm: '96',
        mmhg: '98/120'
      },
    ]
  }
  return {
    content: content
  }
}

// 拦截ajax请求，配置mock的数据
Mock.mock('/getFamilyData', 'get', family)
Mock.mock('/delFamily', 'post', delFamily)
Mock.mock('/addFmaily', 'post', addFmaily)
Mock.mock('/getDataDetail', 'post', getDataDetail)
